perm filename POLL.SAI[SAI,LES]1 blob sn#834852 filedate 1987-02-20 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	begin "poll"
C00004 00003				! Main Loop
C00006 ENDMK
C⊗;
begin "poll"
require "head" source_file;
!
Reads the sorted output of FROM and counts response combinations.
1987 Feb. 20  First version by Les Earnest.
;
scnbrk(todot,".[","","IN");

define blanks=[                                        ];
proc lprint(integer l; string s);
    ! prints the leftmost L characters of string S, padding with blanks
      if it is not long enough.;
    if ln(s)<l then print(s,blanks[1 to l-ln(s)]) else print(s[1 to l]);
proc rprint(integer l; string s);
    ! prints the string S right-justified, padding with blanks if needed;
    if ln(s)<l then print(s,blanks[1 to l-ln(s)]) else print(s);
			! Main Loop;
boolean fl;
string filist;
integer filemax;
label restart;

open(inch←getchan,"DSK",1,19,0,400,brk,eof);
restart:
lookup(inch,ask("Source file="),fl);
if fl then begin
    print("Can't be opened"&↓);
    close(inch);
    goto restart
    end;
if lop(filist←inlines)≠" " then begin
    print("File not sorted or wrong type"&↓);
    exit;
    end;
filemax←0;
setprint("","B"):
print("		Readers	");
			! count files and print column headings;
while ln(filist) do begin
    string filen;
    filen←towhites(filist);
    lprint(8,todot(filen));
    filemax←filemax + 1;
    end;
print(↓);
begin "sum"
    integer readers;
    integer array filcnt[1:filemax];		! number of yeses;
    integer array combo[1:(1 ash filemax)-1];	! combinations of yeses;
    string aline,ohost,oid;

    ohost←oid←"";
    while ln(aline←inlines) do begin
	string host,id;
	integer fileno;

	host←towhites(aline);
	id←towhites(aline);
	if (fileno←cvd(aline))≤0 then begin
	    print("No file number for ",host," ",id,↓);
	    exit
	    end;
	if ≤equ(ohost,host) then